package com.niuquan.base_function;

import android.content.Context;
import android.content.SharedPreferences;

public class cache_core {
	

	    public static final String PREFERENCE_NAME = "local_userinfo";
	    protected static cache_core cache_utils = null;
	    protected static SharedPreferences mSharedPreferences;
	    protected static SharedPreferences.Editor editor;

	    protected cache_core(Context cxt) {
	        mSharedPreferences = cxt.getSharedPreferences(PREFERENCE_NAME,Context.MODE_PRIVATE);
	    }

	    protected cache_core(Context cxt,String name) {
	        mSharedPreferences = cxt.getSharedPreferences(name,Context.MODE_PRIVATE);
	    }
	    

	    public static cache_core getInstance(Context cxt) {
	        if (cache_utils == null) {
	        	cache_utils = new cache_core(cxt);
	        }
	        editor = mSharedPreferences.edit();
	        return cache_utils;
	    }

	    public static cache_core getInstance(Context cxt,String name) {
	        if (cache_utils == null) {
	        	cache_utils = new cache_core(cxt,name);
	        }
	        editor = mSharedPreferences.edit();
	        return cache_utils;
	    }
	    
	    //
	    public void setUserInfo(String str_name, String str_value) {
	        editor.putString(str_name, str_value);
	        editor.commit();
	    }
	    public String getUserInfo(String str_name) {
	        return mSharedPreferences.getString(str_name, "");
	    }
}
